<?php

namespace app\core\exception;

class ErrorCode
{

    const COMMON_SUCCESS = 0;//操作成功
    const COMMON_ERROR = 1;//操作失败
    /**
     * 系统错误或者参数错误
     */
    const COMMON_SYSTEM_ERROR = 100000;//网络错误，请稍后再试
    const COMMON_INVALID_PARAMS = 100001;//请求参数错误
    const COMMON_LACK_PARAMS = 100002;//缺少必要的参数
    const COMMON_MUST_FILL = 100003;//必填
    const COMMON_PREVENT_REPEAT_SUBMIT = 1000004;//禁止重复提交

    const MINI_PROGRAM_SYSTEM_ERROR = 200000;//网络错误，请稍后再试
    const MINI_PROGRAM_INVALID_PARAMS = 200001;//请求参数错误
    const MINI_PROGRAM_LACK_PARAMS = 200002;//缺少必要的参数

    const MINI_PROGRAM_SESSION_KEY_EXPIRE = 210000;//session_key过期



    /** --------------------    业务错误码    统一通过Business及其子类抛出   --------------------------   */

    /**
     * 用户相关.
     */
    const USER_NOT_FOUND = 300001;  //账户不存在
    const USER_NOT_LOGIN = 300002;  //未登录
    const USER_LOGIN_PASSWORD_ERROR = 300003; //密码错误
    const USER_ACCOUNT_DISABLE = 300004;//账号被禁用
    const USER_ACCOUNT_LOGOUT = 300005;//账号已注销
    const USER_LOGIN_MORE_ERROR = 300006;//登陆次数过多
    const USER_LOGIN_EMPTY_TOKEN = 300007;//token为空
    const USER_LOGIN_INVALID_TOKEN = 300008;//token无效

    /**
     * 权限相关
     */
    const AUTH_PERMISSION_DENIED = 400000; //权限不足
    const AUTH_VALIDATE_DENIED = 400001;//无权限操作


    /**
     * 数据库查询及操作相关
     */
    const DATA_OPERATE_FAIL = 500001;//操作数据失败
    const DATA_NOT_FOUND = 500002;//数据不存在

    const HOOK_AFTER_LISTEN_EXCEPTION = 600001;//后置行为发生异常
    const HOOK_BEFORE_LISTEN_EXCEPTION = 600002;//前置行为发生异常

    const CURRENCY_NOT_ENOUGH = 800000;//心愿值不足

    const ROBOT_SUPPORT_SUCCESS = 900000;//机器人支持成功

    const SYSTEM_ERROR = 999999;


    /**
     * 错误码对应文案.
     */
    const ERROR_MSG = [
        self::COMMON_SUCCESS => '操作成功',
        self::COMMON_ERROR => '操作失败',
        self::COMMON_SYSTEM_ERROR => '网络错误，请稍后再试',
        self::COMMON_INVALID_PARAMS => '请求参数错误',
        self::COMMON_LACK_PARAMS => '缺少必要的参数',
        self::COMMON_MUST_FILL => '必填',
        self::COMMON_PREVENT_REPEAT_SUBMIT => '禁止重复提交',
        self::USER_NOT_FOUND => '账户不存在',
        self::USER_NOT_LOGIN => '登录状态已失效，请重新登录',
        self::USER_LOGIN_PASSWORD_ERROR => '密码错误',
        self::USER_ACCOUNT_DISABLE => '账号被禁用',
        self::USER_ACCOUNT_LOGOUT => '账号已注销',
        self::USER_LOGIN_MORE_ERROR => '登陆次数过多，请稍后再试',
        self::USER_LOGIN_EMPTY_TOKEN => 'token为空',
        self::USER_LOGIN_INVALID_TOKEN => 'token无效',
        self::AUTH_PERMISSION_DENIED => '权限不足',
        self::AUTH_VALIDATE_DENIED => '无权限操作',
        self::DATA_OPERATE_FAIL => '操作数据失败',
        self::DATA_NOT_FOUND => '数据不存在',
        self::HOOK_AFTER_LISTEN_EXCEPTION => '后置行为发生异常',
        self::HOOK_BEFORE_LISTEN_EXCEPTION => '前置行为发生异常',

        self::CURRENCY_NOT_ENOUGH => '心愿值不足',

        self::SYSTEM_ERROR => '系统错误',


        self::MINI_PROGRAM_SYSTEM_ERROR => '网络错误，请稍后再试',
        self::MINI_PROGRAM_INVALID_PARAMS => '请求参数错误',
        self::MINI_PROGRAM_LACK_PARAMS => '缺少必要的参数',
        self::MINI_PROGRAM_SESSION_KEY_EXPIRE => '微信登录过期，请重新登录',
    ];
}
